package cosc617_blackteam;
/**
 * This class will have the tab of an individual customer only and if the tab amount
 * is more than $100.00, 5% discount will be applied
 */
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Locale;

public class SimpleTab extends I_Tab {
	private ArrayList<Order>orderOfIndividual= new ArrayList<Order>();
	

	public SimpleTab(CustomerParty party){
		orderOfIndividual = new ArrayList<Order>();
		//orders are going to get removed from the original list
		BigDecimal tabTotal = new BigDecimal("0");
		for(Order order : party.getPartyOrders()){
			orderOfIndividual.add(order);
			tabTotal = tabTotal.add(order.price());
		}
		setTabValue(tabTotal);
		
	}

	public String makeRegularTab(){
		String output = "\tRECEIPT\n" 
				+ "======================================" +
				"\nItem Name \t\t" +"Item Price\n";
		final NumberFormat currencyInstance = NumberFormat.getCurrencyInstance(new Locale("en", "US"));
		for(Order order : orderOfIndividual){

			String name=order.name();
			BigDecimal price=order.price();
			
			String p = currencyInstance.format(price.doubleValue());
			output += String.format("%-12.12s\t\t",name) + p + "\n";
					


		}
		output += "______________________________________\n"
				+ "Total:\t\t"
				+ currencyInstance.format(getTabValue().doubleValue())
				+ "\n======================================\n";
		return output;
	}


}
